<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title>Show Course</title>
</head>
<body>
<div class="nav">
    <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}">Home</a></span>
    <span class="menuButton"><g:link class="list" action="list">Course List</g:link></span>
    <span class="menuButton"><g:link class="create" action="create">New Course</g:link></span>
</div>
<div class="body">
    <h1>Show Course</h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <div class="dialog">

        <table class="main">
            <tbody>
                <tr>
                    <td>
                        <table>
                            <tbody>

                                <tr class="prop">
                                    <td>
                                        <h2>Dane główne:</h2>
                                    </td>
                                </tr>

                                <tr class="prop">
                                    <td valign="top" class="name">Id:</td>

                                    <td valign="top" class="value">${fieldValue(bean: course, field: 'id')}</td>

                                </tr>

                                <tr class="prop">
                                    <td valign="top" class="name">Liczba Semestrow:</td>

                                    <td valign="top" class="value">${fieldValue(bean: course, field: 'liczbaSemestrow')}</td>

                                </tr>

                                <tr class="prop">
                                    <td valign="top" class="name">Nazwa Kierunku:</td>

                                    <td valign="top" class="value">${fieldValue(bean: course, field: 'nazwaKierunku')}</td>

                                </tr>

                                <tr class="prop">
                                    <td valign="top" class="name">Osoba Prowadzaca:</td>

                                    <td valign="top" class="value">${fieldValue(bean: course, field: 'osobaProwadzaca')}</td>

                                </tr>

                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>

        <g:form>
            <input type="hidden" name="id" value="${course?.id}"/>
            <span class="button"><g:actionSubmit class="edit" action="edit" value="Edytuj" class="icon-button-edit"/></span>
            <span class="button"><g:actionSubmit class="delete" action="delete" onclick="return confirm('Are you sure?');" value="Usuń Konto" class="icon-button-delete"/></span>
        </g:form>

        <h1>Prowadzący:</h1>

        <div class="list">
            <table class="list">
                <thead>
                    <tr>

                        <g:sortableColumn property="id" title="Id"/>

                        <g:sortableColumn property="username" title="Username"/>

                        <g:sortableColumn property="userRealName" title="User Real Name"/>

                        <g:sortableColumn property="passwd" title="Passwd"/>

                        <g:sortableColumn property="enabled" title="Enabled"/>

                        <g:sortableColumn property="description" title="Description"/>

                        <g:sortableColumn property="id" title="Szczegóły"/>

                    </tr>
                </thead>
                <tbody>
                    <g:each in="${teacherList?.prowadzacy?}" status="i" var="teacher">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

                            <td>${fieldValue(bean: teacher, field: 'id')}</td>

                            <td>${fieldValue(bean: teacher, field: 'username')}</td>

                            <td>${fieldValue(bean: teacher, field: 'userRealName')}</td>

                            <td>${fieldValue(bean: teacher, field: 'passwd')}</td>

                            <td>${fieldValue(bean: teacher, field: 'enabled')}</td>

                            <td>${fieldValue(bean: teacher, field: 'description')}</td>

                            <td><g:link action="show" id="${teacher.id}">Szczegóły..</g:link></td>

                        </tr>
                    </g:each>
                </tbody>
            </table>

            <tr class="prop">

                <td valign="top" style="text-align:left;" class="value">
                    <ul>
                        <g:each var="p" in="${course.prowadzacy}">
                            <li><g:link controller="courseTeacher" action="show" id="${p.id}">${p?.encodeAsHTML()}</g:link></li>
                        </g:each>
                    </ul>
                </td>

            </tr>

            <h1>Studenci:</h1>

            <div class="list">
                <table class="list">
                    <thead>
                        <tr>

                            <g:sortableColumn property="id" title="Id"/>

                            <g:sortableColumn property="imie" title="Imie"/>

                            <g:sortableColumn property="username" title="Nazwisko"/>

                            <g:sortableColumn property="userRealName" title="Kierunek"/>

                            <g:sortableColumn property="passwd" title="NIP"/>

                            <g:sortableColumn property="enabled" title="PESEL"/>

                            <g:sortableColumn property="id" title="Szczegóły"/>

                        </tr>
                    </thead>
                    <tbody>
                        <g:each in="${course.studenci}" status="i" var="student">
                            <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

                                <td>${fieldValue(bean: student, field: 'id')}</td>

                                <td>${fieldValue(bean: student, field: 'imie')}</td>

                                <td>${fieldValue(bean: student, field: 'nazwisko')}</td>

                                <td>${fieldValue(bean: student, field: 'kierunekStudiowPodyplomowych')}</td>

                                <td>${fieldValue(bean: student, field: 'NIP')}</td>

                                <td>${fieldValue(bean: student, field: 'PESEL')}</td>

                                <td><g:link action="show" id="${student.id}">Szczegóły..</g:link></td>

                            </tr>
                        </g:each>
                    </tbody>
                </table>
            </div>

        </div>

    </div>
</body>
</html>
